<%--
  Created by IntelliJ IDEA.
  User: shen
  Date: 2020/2/11
  Time: 11:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="${basePath}"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>一级知识点分类</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

    <%@include file="../common_resource.jsp" %>
    <script type="text/javascript">
        function doDelete(levKldID){
            $("#delSureModal").modal();
            $("#sureBtn").click(function(){
                $("#sureBtn").attr("data-dismiss","modal");
                $.get("Kld/deleteLevKld",{"levKldID":levKldID},function(json){
                    if(json.delLevCtgr==1){
                        $("#row"+levKldID).remove();
                        $("#delSuccessModal").modal();
                    }else{
                        $("#delFailModal").modal();
                    }
                });
            });

        }

        function doUpdate(levKldID){
            var o=document.getElementById("update"+levKldID);
            o.style.display = "block";

            var title=document.getElementById("name"+levKldID);
            title.style.display = "none";
        }

        function doCanncel(levKldID){
            var o=document.getElementById("update"+levKldID);
            var title=document.getElementById("name"+levKldID);

            title.style.display = "block";
            o.style.display = "none";
        }

        function levKldUpdate(levKldID){
            var value=$("#newvalue"+levKldID).val();
            $.post("Kld/updateLevKld",{"levKldCtgr":value,"levKldID":levKldID},function(json){
                if(json!=null){
                    $("#successModal").modal();
                    var o=document.getElementById("update"+levKldID);
                    var title=document.getElementById("name"+levKldID);

                    title.style.display = "block";
                    o.style.display = "none";
                    $("#name"+levKldID).html(value);
                }else{
                    $("#faillModal").modal();
                }
            });

        }
        /* 判断是否成功插入一级知识点*/
        <c:if test="${not empty sessionScope.insertLevKdl}">
        $(function(){
            $("#insertSuccessModal").modal();
        });
        </c:if>
        <c:if test="${0 eq sessionScope.insertLevKdl}">
        $(function(){
            $("#insertFailModal").modal();
        });
        </c:if>
    </script>
    <style type="text/css">
        .msg{
            color: red;
            font-style: italic;
            font-weight: normal;
            padding-top: 5px;
        }
        .listData_btn{
            font-size: 11px;
            margin:0px;
        }
    </style>
</head>
<body class="main_body">
<div class="container container-1180" >
    <div class="col" style="margin-top: 10px;">
        <div class="panel panel-info">
            <div class="panel-heading">
                <span ><i class="fa fa-user"></i></span> <label><font style="font-weight: bold;margin-left: 10px;font-size: 17px">新&nbsp;增&nbsp;一&nbsp;级&nbsp;知&nbsp;识&nbsp;点</font></label>
            </div>
            <div class="panel-body">
                <form id="catagoryForm" action="Kld/insertLevKld" method="post" style="margin-left: -200px;">
                    <fieldset style="width: 550px;margin-left:230px; border: 2px; position: relative;top: 15px;">
                        <table style="margin-left:130px; position: relative;top:20px;" width="583px;" cellpadding="0" cellspacing="0" border="0px" >
                            <tr>
                                <label class="col-sm-3 control-label" style="font-size: 14px;">一级知识点： </label>
                                <div class="col-sm-4" style="margin-left: -30px;">
                                    <input name="levKldCtgr" type="text" id="levKldCtgrInsert" placeholder="请输入一级知识点" class="easyui-validatebox form-control "  required="true"/>
                                    <div id="addOptMsg" class="msg"></div>
                                    <br>
                                    <input type="submit" value="保存" class="button_b"/>&nbsp;&nbsp;&nbsp;&nbsp;
                                    <input type="reset" value="重置" class="button_h"/>
                                </div><br/>
                            </tr>
                        </table>
                    </fieldset>
                </form>
                <div class="panel panel-warning" style="margin-top: 40px">
                    <div class="panel-heading">
                        <h3 class="panel-title"><span class="glyphicon glyphicon-th-list"></span>&nbsp;一级知识点信息</h3>
                    </div>
                    <div class="panel-body">
                        <!--做查询的表单-->
                        <form action="Kld/selectAllLevByRequest/0"  class="form-inline" method="post">
                            <div class="row clearfix">

                                <div class="col-md-12 column">
                                    <div class="form-group">
                                        <div class="input-group">
                                            <div class="input-group-addon">一级知识点：</div>
                                            <input type="text" class="form-control" name="levKldCtgr" value="<%=request.getParameter("levKldCtgr")==null ? "" : request.getParameter("levKldCtgr")%>" placeholder="请输入一级知识点内容">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="input-group">
                                            <button type="submit" class="btn btn-info" style="margin-left: 10px">查询</button>
                                            <button type="reset" class="btn btn-default" style="margin-left: 10px">重置</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>

                        <table class="table table-hover" style="margin-left:190px; margin-top:50px;font-size: 18px;width: 680px;" >
                            <tr style="height: 25px; font-weight: bold; text-align: center;" class="success">
                                <td align="center" width="60px">序号</td>
                                <td align="center">一级知识点</td>
                                <td align="center" width="160px">操作</td>
                            </tr>
<%--
                            <c:set var="no" value="1" />
--%>
                            <c:forEach var="levKld" items="${levKldList}" varStatus="status">
                                <tr id="row${levKld.levKldID}" style="height: 30px;text-align: center;">
                                    <td align="center" style="font-weight: bold;">${status.count} </td>
                                    <td>
                                        <span id="name${levKld.levKldID }" style="display: block;">${levKld.levKldCtgr}</span>
                                        <span id="update${levKld.levKldID }" style="display: none">
				   				             <span  class="col-sm-9">
					   				               <input type="text" id="newvalue${levKld.levKldID }" value="${levKld.levKldCtgr}" size="33" class="form-control"/>
					   			             </span>
					   			             <span class="col-sm-3">
					   				             <input type="button" value="确认" onclick="levKldUpdate(${levKld.levKldID})" class="btn btn-info btn-xs"/>
					   				             <input type="button" value="取消" onclick="doCanncel(${levKld.levKldID})" class="btn btn-warning btn-xs"/>
					   			             </span>
                                         </span>
                                    </td>
                                    <td align="center" style="width: 80px">
                                        <a class="btn btn-info btn-sm" id="button${levKld.levKldID}" onclick="doUpdate(${levKld.levKldID});"><i class="fa fa-edit fa-white"></i>
                                            编辑
                                        </a>&nbsp;&nbsp;
                                        <a class="btn btn-danger btn-sm" id="button${levKld.levKldID}" onclick="doDelete(${levKld.levKldID});"><i class="glyphicon glyphicon-trash"></i>
                                            删除
                                        </a>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="3" style="height: 8px;"></td>
                                </tr>
<%--
                                <c:set var="no" value="${no+1 }" />
--%>
                            </c:forEach>
                        </table>
                        <div class="pager" style="padding-left:50px;background-color: #FAEBD7">
                            <%--分页显示--%>
                            总${levKldList.getTotal()}条 &nbsp;&nbsp; 第${levKldList.getPageNum()}页/共${levKldList.getPages()}页
                            &nbsp;&nbsp; &nbsp;&nbsp;
                            <c:if test="${levKldList.getPageNum() gt 1}">
                                <a href="Kld/selectAllLevByRequest/1">第一页</a> &nbsp;
                            </c:if>
                            <c:if test="${levKldList.getPageNum() gt 1}">
                                <a href="Kld/selectAllLevByRequest/${levKldList.getPageNum()-1}">上一页</a>&nbsp;
                            </c:if>
                            <c:if test="${levKldList.getPageNum() lt (levKldList.getPages())}">
                                <a href="Kld/selectAllLevByRequest/${levKldList.getPageNum()+1}">下一页</a>&nbsp;
                            </c:if>
                            <c:if test="${levKldList.getPageNum() lt levKldList.getPages()}">
                                <a href="Kld/selectAllLevByRequest/${levKldList.getPages()}">末页</a>&nbsp;
                            </c:if>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Mainly scripts -->
<script src="bootstrap/js/bootstrap.js"></script>

<%--<%@include file="../myModal.jsp" %>--%>
<!-- 添加成功模态 -->
<div class="modal fade" id="insertSuccessModal" tabindex="-1" role="dialog"
     aria-labelledby="insertSuccessModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal1">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3>一级知识点添加成功</h3>
            </div>
            <div class="modal-footer">
                <button id="closeModal" type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 添加失败模态 -->
<div class="modal fade" id="insertFailModal" tabindex="-1" role="dialog"
     aria-labelledby="insertFailModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal2">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3>添加失败</h3>
            </div>
            <div class="modal-footer">
                <button  type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 更新成功模态 -->
<div class="modal fade" id="successModal" tabindex="-1" role="dialog"
     aria-labelledby="successModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal3">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3>更新一级知识点成功</h3>
            </div>
            <div class="modal-footer">
                <button id="closeSuccessModal" type="button" class="btn btn-default" data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 更新失败modal -->
<div class="modal fade" id="failModal" tabindex="-1" role="dialog"
     aria-labelledby="feildModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal4">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                更新一级知识点失败
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除警告模态 -->

<div class="modal fade" id="dangerModal" tabindex="-1" role="dialog"
     aria-labelledby="selectDengerModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" >
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModal5">
                    <span style="font-size: 40px;"><i class="fa fa-exclamation-circle"></i>警告!</span>
                </h4>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3 style="color:red;">请至少选择一项!</h3>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger"
                        data-dismiss="modal">确定
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 删除确认模态 -->
<div class="modal fade" id="delSureModal" tabindex="-1" role="dialog"
     aria-labelledby="delOKModalModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal6">
                    <i class="fa fa-exclamation-circle"></i>&nbsp;&nbsp;删除警告！</span>
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3 style="color: red;">删除后就不可恢复</h3>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-denger"
                        data-dismiss="modal">关闭
                </button>
                <button id="sureBtn" type="button" class="btn btn-primary" >确认删除</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 删除成功模态 -->

<div class="modal fade" id="delSuccessModal" tabindex="-1" role="dialog"
     aria-labelledby="delSuccessModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModal7">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;删除成功提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3 class="text-success">删除 成功</h3>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">确定
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 删除失败modal -->
<div class="modal fade" id="delFailModal" tabindex="-1" role="dialog"
     aria-labelledby="delFeildModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h2 class="modal-title" id="myModalLabel">
                    <i class="fa fa-twitch"></i> &nbsp;&nbsp;删除失败提示
                </h2>
            </div>
            <div class="modal-body" style="text-align:center;">
                <h3 style="color: red;">该知识点正在被使用，不能删除</h3>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">确定
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


</body>
</html>
<c:remove var="insertLevKdl" scope="session"/>